//
//  ArmItemInfoView.m
//  wAudioShare
//
//  Created by Anson on 14/11/18.
//  Copyright (c) 2014年 赵帅. All rights reserved.
//

#import "ArmItemInfoView.h"

#import "ArmModel.h"

@interface ArmItemInfoView ()

@property (weak, nonatomic) IBOutlet UITextField *tfArmName;
@property (weak, nonatomic) IBOutlet UISwitch *swNotification;
@property (weak, nonatomic) IBOutlet UILabel *labelNotification;
@property (weak, nonatomic) IBOutlet UIButton *btnConfirm;

@property (nonatomic,retain) ArmModel *armData;

@end

@implementation ArmItemInfoView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(void)initView
{
    self.layer.masksToBounds = YES;
    self.layer.borderWidth = 1;
    self.layer.cornerRadius = 8;
    self.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    [self setContentMode:UIViewContentModeScaleAspectFill];
    [self setClipsToBounds:YES];
    
}

- (void)setArmItemInfoData:(ArmModel *)data {
    self.armData = data;
    
    self.tfArmName.text = self.armData.label;
    self.labelNotification.text = (self.armData.notify ? @"是":@"否");
    //[self.swNotification setOn:self.armData.notify];
}

- (IBAction)onConfirmBtnClicked:(id)sender {
    
    if ([self.armData.label isEqualToString:self.tfArmName.text]) {
        if (self.delegate && [self.delegate respondsToSelector:@selector(armItemInfoView:armChangeName:)]) {
            [self.delegate armItemInfoView:self armChangeName:self.tfArmName.text];
        }
    }
    
}

@end
